package com.kclmedu.sst.encoder;

import org.springframework.security.crypto.password.PasswordEncoder;

/************
 * 密码加密器,在 spring security 5.x版本中，必需要指定 passwordEncoder，否则，会出现NoPasswordEncoder异常
 */
public class MyPasswordEncoder implements PasswordEncoder {

    @Override
    public String encode(CharSequence charSequence) {
        System.out.printf("--- MyPasswordEncoder's encode()方法, charSequence: %s\n", charSequence);
        return charSequence.toString();
    }

    @Override
    public boolean matches(CharSequence charSequence, String s) {
        System.out.printf("--- MyPasswordEncoder's matches()方法, charSequence: %s, s: %s\n", charSequence, s);
        return s.equals(charSequence.toString());
    }
}
